package com.dytj.dao;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import com.dytj.pojo.Administration;
import com.mysql.jdbc.Connection;
import com.mysql.jdbc.Statement;

public class AdministrationDao {
	
//	public static Administration addAdministration() throws SQLException {
//		Administration administration = new Administration();
//		Connection conn = (Connection) DBUtil.getConn();
//		Statement st = (Statement) conn.createStatement();
//		//sql处理
//		String sql = "";
//		ResultSet rs = st.executeQuery(sql);
//		while(rs.next()){
//			
//		}
//		rs.close();
//		st.close();
//		conn.close();
//		return administration;
//	}
	
	public static List<Administration> adminCheck(Administration administration)throws SQLException{
		String accounts = administration.getAccounts();
		String password = administration.getPassword();
		Connection conn = (Connection) DBUtil.getConn();
		Statement st = (Statement) conn.createStatement();
		String sql = "select * from administration where accounts = '"+accounts+"' and  password = '" +password+"'";
		ResultSet rs = st.executeQuery(sql);
		List<Administration> list = new ArrayList<Administration>();
		while(rs.next()){
			Administration administrationValue = new Administration();
			administrationValue.setAdministrationId(rs.getInt("administration_id"));
			administrationValue.setAccounts(rs.getString("accounts"));
			administrationValue.setPassword(rs.getString("password"));
			list.add(administrationValue);
		}
		rs.close();
		st.close();
		conn.close();
		return list;
	}
	
}
